{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 区间上 $p$ 次拉格朗日基函数的构造\n",
    "\n",
    "给定区间单元上的一个重心坐标 $(\\lambda_0, \\lambda_1)$, 所有 $p\\geq 1$ 次基函数的计算公式如下:\n",
    "\n",
    "$$\n",
    "\\phi_{m,n} = \\frac{p^p}{m!n!}\\prod_{l_0 = 0}^{m - 1}\n",
    "(\\lambda_0 - \\frac{l_0}{p}) \\prod_{l_1 = 0}^{n-1}(\\lambda_1 -\n",
    "\\frac{l_1}{p}).\n",
    "$$\n",
    "\n",
    "其中 $ m\\geq 0$, $n\\geq 0$, 且 $m+n=p$, 这里规定:\n",
    "\n",
    "$$\n",
    " \\prod_{l_i=0}^{-1}(\\lambda_i - \\frac{l_i}{p}) := 1,\\quad i=0, 1, 2\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## $p$ 次基函数的矩阵计算公式\n",
    "\n",
    "构造向量：\n",
    "$$\n",
    "P = ( \\frac{1}{0!},  \\frac{1}{1!}, \\frac{1}{2!}, \\cdots, \\frac{1}{p!})\n",
    "$$\n",
    "\n",
    "构造矩阵：\n",
    "$$\n",
    "A :=                                                                            \n",
    "\\begin{pmatrix}  \n",
    "1  &  1  \\\\\n",
    "\\lambda_0 & \\lambda_1\\\\                                             \n",
    "\\lambda_0 - \\frac{1}{p} & \\lambda_1 - \\frac{1}{p}\\\\   \n",
    "\\vdots & \\vdots \\\\                                                     \n",
    "\\lambda_0 - \\frac{p - 1}{p} & \\lambda_1 - \\frac{p - 1}{p}\n",
    "\\end{pmatrix}                                                                   \n",
    "$$ \n",
    "\n",
    "对 $A$ 的每一列做累乘运算, 并左乘由 $P$ 形成的对角矩阵, 得矩阵:\n",
    "\n",
    "$$\n",
    "B = \\mathrm{diag}(P)\n",
    "\\begin{pmatrix}\n",
    "1 & 1\\\\\n",
    "\\lambda_0 & \\lambda_1\\\\\n",
    "\\prod_{l=0}^{1}(\\lambda_0 - \\frac{l}{p}) & \\prod_{l=0}^{1}(\\lambda_1 - \\frac{l}{p})\\\\\n",
    "\\vdots & \\vdots \\\\\n",
    "\\prod_{l=0}^{p-1}(\\lambda_0 - \\frac{l}{p}) & \\prod_{l=0}^{p-1}(\\lambda_1 - \\frac{l}{p}) \n",
    "\\end{pmatrix}\n",
    "$$\n",
    "\n",
    "易知, 只需从 $B$ 的每一列中各选择一项相乘(要求二项次数之和为 $p$), 再乘以 $p^p$ 即可得到相应的基函数, 其中取法共有 \n",
    "\n",
    "$$\n",
    "n_{dof} = {p+1}\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 双 $p$ 次空间\n",
    "\n",
    "$$\n",
    "N_k = (p+1)*(p+1)\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## p = 1\n",
    "\n",
    "$$\n",
    "\\begin{align}\n",
    "\\lambda_0 =& (1 - \\xi)(1 - \\eta)\\\\\n",
    "\\lambda_1 =& \\xi(1 - \\eta) \\\\\n",
    "\\lambda_2 =& \\xi\\eta \\\\\n",
    "\\lambda_3 =& (1 - \\xi)\\eta\\\\\n",
    "\\end{align}\n",
    "$$\n",
    "\n",
    "其中 $(\\xi, \\eta)$ 是参考单元坐标， $\\mathbf x = (x, y)$ 是实际单元坐标。 给定 $E := (\\mathbf x_0, \\mathbf x_1, \\mathbf x_2, \\mathbf x_3)$ 是一个四边形区域，对任意 $x \\in E$, 存在 $(\\xi, \\eta)$ :\n",
    "\n",
    "$$\n",
    "\\mathbf x = \\mathbf x_0\\lambda_0 + \\mathbf x_1\\lambda_1 + \\mathbf x_2 \\lambda_2 + \\mathbf x_3 \\lambda_3\n",
    "$$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
